﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Telerik.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace TPCN.Common
{
    public static class ControlHelper
    {
        public static void ResetControl(Control parent)
        {
            foreach (Control c in parent.Controls)
            {
                if (c != null)
                {
                    if (c.Controls.Count > 0)
                    {
                        if (c is RadEditor)
                            ((RadEditor)c).Content = String.Empty;
                        else
                            ControlHelper.ResetControl(c);
                    }
                    else
                    {
                        if (c is Button)
                            continue;
                        else if (c is TextBox)
                            ((TextBox)c).Text = String.Empty;
                        else if (c is DropDownList)
                            ((DropDownList)c).SelectedIndex = -1;
                        else if (c is CheckBox)
                            ((CheckBox)c).Checked = false;
                        else if (c is RadioButton)
                            ((RadioButton)c).Checked = false;
                        else if (c is Image)
                            ((Image)c).ImageUrl = String.Empty;
                        else if (c is RadTextBox)
                            ((RadTextBox)c).Text = String.Empty;
                        else if (c is HtmlSelect)
                            ((HtmlSelect)c).SelectedIndex = 0;
                    }
                }
            }
            return;
        }
    }
}